class Solution
{
public:
    vector<string> commonChars(vector<string> &words)
    {
        vector<int> charCount(26, 100);
        for (auto &word : words)
        {
            int thisCharCount[26] = {0};
            for (char c : word)
            {
                ++thisCharCount[c - 'a'];
            }
            for (int i = 0; i < 26; ++i)
            {
                charCount[i] = min(charCount[i], thisCharCount[i]);
            }
        }
        vector<string> result;
        for (int i = 0; i < 26; ++i)
        {
            for (int j = 0; j < charCount[i]; ++j)
            {
                result.emplace_back(1, static_cast<char>(i + 'a'));
            }
        }
        return result;
    }
};